package org.oa.ai.feign;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import org.oa.ai.chatModel.CcCtCwyjyy;
import org.oa.ai.chatModel.OactbdCsqjsq;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.InputStream;
import java.util.Map;

@FeignClient(name = "example-service", url = "${feign.client.url}")
public interface AIFeignClient {

    @PostMapping("/ai/flow/nextTasksByNodeId")
    String nextTasksByNodeId(
            @RequestParam(required = false) String nodeId,
            @RequestParam(required = false) String processDefinitionKey
    );

    @PostMapping("/ai/flow/nextTasksByNodeId")
    String nextTasksByNodeIdCC(
            @RequestParam(required = false) String nodeId,
            @RequestParam(required = false) String processDefinitionKey,
            @RequestParam(required = false) String userId
    );

    @RequestMapping(
            value = {"/ai/flow/getFlowUserByNodeId"},
            method = {RequestMethod.GET},
            produces = {"application/json"}
    )
    public String getFlowUserByNodeId(@RequestParam(required = false) String nodeId,
                                      @RequestParam(required = false) String processDefinitionKey,
                                      @RequestParam(required = false) String startUserId,
                                      @RequestParam(required = false) String assigneeId
    );

    @RequestMapping(
            value = {"/ai/flow/getFlowUserByNodeIdCC"},
            method = {RequestMethod.GET},
            produces = {"application/json"}
    )
    public String getFlowUserByNodeIdCC(@RequestParam(required = false) String nodeId,
                                      @RequestParam(required = false) String processDefinitionKey,
                                      @RequestParam(required = false) String startUserId,
                                      @RequestParam(required = false) String assigneeId,
                                      @RequestParam(required = false) String userId
    );


    @RequestMapping(
            value = {"/ai/flow/startProcessByKeyNew"},
            method = {RequestMethod.POST},
            produces = {"application/json"}
    )
    public Map<String, Object> startProcessByKeyNew(@RequestParam(required = true) String businessKey,
                                                    @RequestParam(required = false) String processDefinitionKey,
                                                    @RequestParam(required = false) String title,
                                                    @RequestParam(required = false) String moduleId,
                                                    @RequestParam(required = false) String firstNode,
                                                    @RequestParam(required = false) String reportStatus,
                                                    @RequestParam(required = false) String mijiid,
                                                    @RequestParam(required = false) String tableName,
                                                    @RequestParam(required = false) String comminfoId,
                                                    @RequestParam(required = false) String userId,
                                                    @RequestParam(required = false) String formType);

    @RequestMapping(
            value = {"/ai/flow/startProcessByKeyNewCC"},
            method = {RequestMethod.POST},
            produces = {"application/json"}
    )
    public Map<String, Object> startProcessByKeyNewCC(@RequestParam(required = true) String businessKey,
                                                    @RequestParam(required = false) String processDefinitionKey,
                                                    @RequestParam(required = false) String title,
                                                    @RequestParam(required = false) String moduleId,
                                                    @RequestParam(required = false) String firstNode,
                                                    @RequestParam(required = false) String reportStatus,
                                                    @RequestParam(required = false) String mijiid,
                                                    @RequestParam(required = false) String tableName,
                                                    @RequestParam(required = false) String comminfoId,
                                                    @RequestParam(required = false) String userId,
                                                    @RequestParam(required = false) String formType);

    @PostMapping("/ai/flow/updateReportStatus")
    public Boolean updateReportStatus(@RequestParam(required = true) String taskId,
                                         @RequestParam(required = true) String reportStatus);

    @RequestMapping(
            value = {"/ai/flow/taskCompleteNew"},
            method = {RequestMethod.POST},
            produces = {"application/json"}
    )
    public Map<String, Object> taskCompleteNew(@RequestParam(required = true) String businessKey,
                                               @RequestParam(required = true) String currentTaskId,
                                               @RequestParam(required = true) String nextTaskActivityId,
                                               @RequestParam(required = true) String nextTaskUserIds,
                                               @RequestParam(required = true) String nextTaskUsernames,
                                               @RequestParam(required = false) String assigneeId,
                                               @RequestParam(required = false) String moduleId,
                                               @RequestParam(required = false) String nodeName,
                                               @RequestParam(required = false) String reportStatus,
                                               @RequestParam(required = false) String nodeCode,
                                               @RequestParam(required = false) String rwlxs,
                                               @RequestParam(required = false) String exField5,
                                               @RequestParam(required = false) String processDefinitionId, // 流程监控传入piid
                                               @RequestParam(required = false) String currentNodeId, // 流程监控传入的 nodeid
                                               @RequestParam(required = false) String tjlx,   // 提交类型，判断不为空并且等于 lcjk 说明是流程监控提交的
                                               @RequestParam(required = false) String logtype,//jump流程跳转
                                               @RequestParam(required = false) String tableName,
                                               @RequestParam(required = false) String comminfoId,
                                               @RequestParam(required = false) String processDefinitionKey,
                                               @RequestParam(required = false) String formType,
                                               @RequestParam(required = false) String userId
    );

    @PostMapping("/ai/flow/addForm")
    public OactbdCsqjsq add(@RequestBody OactbdCsqjsq oactbdCsqjsq);

    @GetMapping("/ai/flow/getDataById/{id}")
    public OactbdCsqjsq getDataById(@PathVariable("id") String id);

    @GetMapping(value = "/ai/flow/getFileContent/{id}")
    public String getFileContent(@PathVariable("id") String id);

    @GetMapping(value = "/ai/flow/getFileByGwid/{id}")
    public File getFileByGwid(@PathVariable("id") String id);

    @PostMapping("/ai/flow/cc/addForm")
    public Map<String, Object> addForm(@RequestBody Map<String, Object> map);

    @GetMapping("/ai/flow/cc/getDataById/{tableName}/{id}")
    public Map<String, Object> getDataByIdByCC(@PathVariable("tableName") String tableName, @PathVariable("id") String id);

    @GetMapping("/ai/flow/cc/getUserByDeptId/{id}")
    public JSONArray getYcrList(@PathVariable("id") String loginDeptId);

    @PostMapping(value = "/ai/flow/common/fileUpload/{gwid}/{ywlx}/{userId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public JSONObject fileUpload(@RequestPart("file") MultipartFile file, @PathVariable("gwid") String gwid, @PathVariable("ywlx") String ywlx, @PathVariable("userId") String userId);

    @GetMapping("/ai/flow/getAllUsers/{id}")
    JSONArray getAllUsers(@PathVariable("id") String userId);

}